import java.util.Scanner;

/**
 * @description: 求任意自然数各位数之和
 * @author: WangBlue
 * @create: 2023-10-28 16:54
 **/
public class GetSum {
    public static void main(String[] args) {
        System.out.println("请输入你的数值");
        int number = new Scanner(System.in).nextInt();
        int sum = 0;
        while (number != 0) {
            // 取出每个数的尾数
            sum = sum + number % 10;
            // 对每个数进行除以10得到商值。
            number = number / 10;
        }
        System.out.println("任意自然数各位数之和为: " + sum);

    }


}
